cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
set(CMAKE_SUPPRESS_REGENERATION true)
set(CMAKE_CXX_STANDARD 17)
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format-security -Wno-format-truncation")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-security -Wno-format-truncation")
endif()
project("LAStools" CXX C)

if (NOT(MSVC))
	add_compile_options(-O3 -Wall -Wno-strict-aliasing)
    add_compile_options(-Wno-unknown-pragmas)
    if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
        add_compile_options(-Wno-unknown-warning-option)
    endif()
else()
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

option(BUILD_SHARED_LIBS "Build LASlib as DLL" OFF)

if (BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
	set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/LASlib")
endif()

add_subdirectory(LASlib/src)
if (NOT BUILD_SHARED_LIBS)
add_subdirectory(src)
endif()
